local skel = fk.CreateSkill {
  name = "emo__jiejing",
  tags = {Skill.Limited},
}

Fk:loadTranslationTable{
  ["emo__jiejing"] = "绕远路便是我的捷径",
  [":emo__jiejing"] = "昂扬技，出牌阶段，你可以被视为使用【杀】并摸两张牌，若你因此受到了伤害则翻面。激昂：你失去了所有手牌或体力。",

  ["#emo__jiejing"] = "你可以被视为使用【杀】，摸两张牌",
}

skel:addEffect("active", {
  prompt = "#emo__jiejing",
  card_num = 0,
  target_num = 0,
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local slash = Fk:cloneCard("slash")
    slash.skillName = skel.name
    local use = {
      from = player, tos = {player}, card = slash, extraUse = true
    }
    room:useCard(use)
    if use.damageDealt and use.damageDealt[player] and not player.dead then
      player:turnOver()
    end
    if player.dead then return end
    player:drawCards(2, skel.name)
  end,
})

skel:addEffect(fk.HpChanged, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:usedSkillTimes(skel.name, Player.HistoryGame) > 0 and
    data.num < 0 and player.hp < 1
  end,
  on_refresh = function (self, event, target, player, data)
    player:clearSkillHistory(skel.name)
  end,
})

skel:addEffect(fk.AfterCardsMove, {
  can_refresh = function(self, event, target, player, data)
    if player.dead or not player:isKongcheng() or player:usedSkillTimes(skel.name, Player.HistoryGame) == 0 then return end
    for _, move in ipairs(data) do
      if move.from == player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand then
            return true
          end
        end
      end
    end
  end,
  on_refresh = function (self, event, target, player, data)
    player:clearSkillHistory(skel.name)
  end,
})

return skel
